/*
 * Copyright 2008-2009 Daniel Freitas
 * 
 * This file is part of Army Creator.
 * 
 * Army Creator is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * Army Creator is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with Army Creator. If not, see
 * <http://www.gnu.org/licenses/>.
 */
package com.googlecode.armycreator.server;

/**
 * Exposes methods to manage the Army Creator server life cycle.
 * 
 * @author <a href="mailto:daniel.mfreitas@gmail.com">Daniel Freitas</a>
 */
public interface ArmyCreatorServer {

    /**
     * Starts the Army Creator application server. Ignores if the server is already running or is starting.
     * 
     * @throws ServerException
     *             If unable to start the server.
     */
    public abstract void start() throws ServerException;

    /**
     * Stop thread execution until the server stops.
     * 
     * @throws InterruptedException
     *             If unable to join the server thread.
     * @throws IllegalStateException
     *             If the server has not yet started.
     * @throws ServerException
     *             If unable to start the server.
     */
    public abstract void join() throws ServerException, InterruptedException, IllegalStateException;

    /**
     * Shutdowns the Army Creator application server. Ignores if the server is already stopped or is stopping.
     * 
     * @throws ServerException
     *             If unable to stop the server.
     */
    public abstract void shutdown() throws ServerException;

    /**
     * Checks if the server is running.
     * 
     * @return <code>true</code> if the server is running, <code>false</code> otherwise.
     */
    public abstract boolean isRunning();

    /**
     * Checks if the server is stopped.
     * 
     * @return <code>true</code> if the server is stopped, <code>false</code> otherwise.
     */
    public abstract boolean isStopped();

    /**
     * Checks if the server has failed to start or to stop.
     * 
     * @return <code>true</code> if the server has failed to start or stop, <code>false</code> otherwise.
     */
    public abstract boolean hasFailed();

}